<template>
  <div>
    <el-dialog
      :title="'角色修改'"
      :visible.sync="info.isshow"
      @close="close"
    >
      user:{{ user }}
      <el-form :model="user">
        <el-form-item label="手机号" label-width="120px">
          <el-input v-model="user.phone" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="昵称" label-width="120px">
          <el-input v-model="user.pickname" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="密码" label-width="120px">
          <el-input v-model="user.password" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="状态" label-width="120px">
          <el-switch
            v-model="user.status"
            :active-value="1"
            :inactive-value="2"
          ></el-switch>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary"  @click="update">修 改</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import {
  reqmemberlist,
  reqmemberedit,
  reqmemberinfo,
} from "../../../http/api";
import { formClose } from "../../../mixins";
import { successAlert } from "../../../utils/alert";
export default {
  // 4.接收info
  props: ["info", "arr"],
  mixins: [formClose],
  data() {
    return {
      // 5.1 初始化表单数据
      user: {
        pickname:"",
        phone:"",
        password:"",
        status:1
      },
      roleList: [],
    };
  },
  computed: {
    ...mapGetters({}),
  },
  mounted() {
    
  },
  methods: {
    ...mapActions({}),
    
    // 清空user
    empty() {
      this.user = {
        pickname:"",
        phone:"",
        password:"",
        status:1
      };
    },
    
    // 8. 获取一条数据
    getOne(id) {
      reqmemberinfo({ uid: id }).then((res) => {
        if (res.data.code === 200) {
          this.user = res.data.list;
          // 补id
          this.user.id = id;
        }
      });
    },
    // 9.修改
    update() {
      reqmemberedit(this.user).then((res) => {
        if (res.data.code == 200) {
          // ①弹成功
          successAlert(res.data.msg);
          // ②弹框内容清空
          this.empty();
          // ③弹框消失
          this.info.isshow = false;
          // ④重新请求列表
          this.$emit("init");
        }
      });
    },
   
  },
};
</script>
<style scoped lang="less">
@import "../../../less/index.less";
</style>